#include "rules.h"
#include "utils.h"
#include <cctype>
#include <iostream>
#include <algorithm>
#include <stdlib.h>

#ifdef DEBUG
#include <iostream>
#endif

bool rule4(std::string key) {
    int sommeHexa = 0;
    for (int i = 0; i < key.length(); i++) {
        switch (key[i]) {
            case 'A':
                sommeHexa += 10;
                break;
            case 'B':
                sommeHexa += 11;
                break;
            case 'C':
                sommeHexa += 12;
                break;
            case 'D':
                sommeHexa += 13;
                break;
            case 'E':
                sommeHexa += 14;
                break;
            case 'F':
                sommeHexa += 15;
                break;
        }
    }
    if (RANGE(sommeChiffre(key) + sommeHexa, 150, 260)) {
        return true;
    }
#ifdef DEBUG
#pragma omp critical
    std::cerr << key << " - R4 : " << (sommeChiffre(key) + sommeHexa) << std::endl;
#endif
    return false;
}